#include "textwindow.h"

TextWindow::TextWindow(QWidget *parent) : QTextEdit(parent)
{
    setAttribute (Qt::WA_DeleteOnClose);    //关闭后销毁窗口
}

void TextWindow::send_close_signal()
{
    emit close_signal(id);
}

TextWindow::~TextWindow()
{

}

void TextWindow::closeEvent(QCloseEvent *e)
{

    if( QMessageBox::question(this, tr("Quit"), tr("Are you sure to quit this application?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes){
        e->accept();//不会将事件传递给组件的父组件
        //qDebug()<<"ok";
        send_close_signal();
    }
    else
      e->ignore();
}
